package com.fatsatsuma.email;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author $Id: EmailTemplate.java,v 1.2 2006/11/21 16:35:58 gevans Exp $
 */
public class EmailTemplate implements Serializable, IEmailTemplate {

	private int id;

	private String name;

	private static final long serialVersionUID = 5374388483254624041L;

	private String to;

	private String from;

	private String cc;

	private String bcc;

	private String subject;

	private String bodyHtml;

	private String bodyText;

	private String contentType;

	private boolean shouldEmbedImages;

	private String imageBasePath;

	/**
	 * @return the imagesBasePath
	 */
	public String getImageBasePath() {
		return imageBasePath;
	}

	/**
	 * @param imagesBasePath
	 *          the imagesBasePath to set
	 */
	public void setImageBasePath(String imageBasePath) {
		this.imageBasePath = imageBasePath;
	}

	/**
	 * @return the shouldEmbedImages
	 */
	public boolean isShouldEmbedImages() {
		return shouldEmbedImages;
	}

	/**
	 * @param shouldEmbedImages
	 *          the shouldEmbedImages to set
	 */
	public void setShouldEmbedImages(boolean shouldEmbedImages) {
		this.shouldEmbedImages = shouldEmbedImages;
	}

	/**
	 * @return Returns the bodyHtml.
	 */
	public String getBodyHtml() {
		return bodyHtml;
	}

	/**
	 * @param bodyHtml
	 *          The bodyHtml to set.
	 */
	public void setBodyHtml(String bodyHtml) {
		this.bodyHtml = bodyHtml;
	}

	/**
	 * @return Returns the bodyText.
	 */
	public String getBodyText() {
		return bodyText;
	}

	/**
	 * @param bodyText
	 *          The bodyText to set.
	 */
	public void setBodyText(String bodyText) {
		this.bodyText = bodyText;
	}

	/**
	 * @return Returns the bcc.
	 */
	public String getBcc() {
		return bcc;
	}

	/**
	 * @param bcc
	 *          The bcc to set.
	 */
	public void setBcc(String bcc) {
		this.bcc = bcc;
	}

	/**
	 * @return Returns the cc.
	 */
	public String getCc() {
		return cc;
	}

	/**
	 * @param cc
	 *          The cc to set.
	 */
	public void setCc(String cc) {
		this.cc = cc;
	}

	/**
	 * @return Returns the contentType.
	 */
	public String getContentType() {
		return contentType;
	}

	/**
	 * @param contentType
	 *          The contentType to set.
	 */
	public void setContentType(String contentType) {
		this.contentType = contentType;
	}

	/**
	 * @return Returns the from.
	 */
	public String getFrom() {
		return from;
	}

	/**
	 * @param from
	 *          The from to set.
	 */
	public void setFrom(String from) {
		this.from = from;
	}

	/**
	 * @return Returns the subject.
	 */
	public String getSubject() {
		return subject;
	}

	/**
	 * @param subject
	 *          The subject to set.
	 */
	public void setSubject(String subject) {
		this.subject = subject;
	}

	/**
	 * @return Returns the to.
	 */
	public String getTo() {
		return to;
	}

	/**
	 * @param to
	 *          The to to set.
	 */
	public void setTo(String to) {
		this.to = to;
	}

	/**
	 * This method generate a list of string email addresses by tokenising the to
	 * field Uses a comma delimited list
	 * 
	 * @return a list of strings, an empty list if there are no values
	 */
	public List<String> getToAddresses() {
		List<String> addresses = new ArrayList<String>();
		String[] splitValues = to.split(",");
		for (String splitValue : splitValues) {
			if (!splitValue.trim().equals("")) {
				addresses.add(splitValue.trim());
			}
		}
		return addresses;
	}

	/**
	 * This method generate a list of string email addresses by tokenising the cc
	 * field Uses a comma delimited list
	 * 
	 * @return a list of strings, an empty list if there are no values
	 */
	public List<String> getCcAddresses() {
		List<String> addresses = new ArrayList<String>();
		String[] splitValues = cc.split(",");
		for (String splitValue : splitValues) {
			if (!splitValue.trim().equals("")) {
				addresses.add(splitValue.trim());
			}
		}
		return addresses;
	}

	/**
	 * This method generate a list of string email addresses by tokenising the bcc
	 * field Uses a comma delimited list
	 * 
	 * @return a list of strings, an empty list if there are no values
	 */
	public List<String> getBccAddresses() {
		List<String> addresses = new ArrayList<String>();
		String[] splitValues = bcc.split(",");
		for (String splitValue : splitValues) {
			if (!splitValue.trim().equals("")) {
				addresses.add(splitValue.trim());
			}
		}
		return addresses;
	}

	/**
	 * @return Returns the id.
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id
	 *          The id to set.
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return Returns the name.
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *          The name to set.
	 */
	public void setName(String name) {
		this.name = name;
	}
}
